package com.dudetest.data.objectify.subclassed;

import com.dudetest.data.DAOFactory;
import com.dudetest.dude.Dude;
import com.dudetest.dude.DudeA;
import com.googlecode.objectify.Key;
import com.googlecode.objectify.annotation.Cached;
import com.googlecode.objectify.annotation.Subclass;

@Subclass
//FIXME Uncomment to get "normal" behaviour
//@Cached
public class DudeASubclassed extends DudeSubclassed implements DudeA {
	private int a;
	
	public DudeASubclassed(){
		super();
	}
	
	public DudeASubclassed(long id){
		super(id);
	}

	@Override
	public Key<? extends Dude> getKey(){
		return new Key<DudeASubclassed>(DudeASubclassed.class,this.getId());
	}

	/*###################################
	 * FROM HERE ON, NOTHING INTERESTING
	 ####################################*/
	
	@Override
	public int getN(){
		return this.getA();
	}
	
	@Override
	public int getA() {
		return this.a;
	}
	
	@Override
	public void setA(int a){
		this.a = a;
	}
	
	@Override
	public String getReference(){
		return DAOFactory.fact().keyToString(this.getKey());
	}
	
	@Override
	public String toString(){
		return "DudeASubclassed = [Id="+this.getId()+", "
			+"Reference="+this.getReference()+", "
			+"Key="+this.getKey()+", "
			+"A="+this.getA()
			+"]";
	}
}
